#include "led.h"

void LED_Init()
{
    GPIO_InitTypeDef iodef;
     
#ifdef USING_BOARD_YELLOW   
    RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB|RCC_APB2Periph_GPIOA|RCC_APB2Periph_AFIO,ENABLE); 
    GPIO_PinRemapConfig(GPIO_Remap_SWJ_JTAGDisable,ENABLE);
    iodef.GPIO_Pin=GPIO_Pin_15;
    iodef.GPIO_Mode=GPIO_Mode_Out_OD;
    iodef.GPIO_Speed=GPIO_Speed_50MHz;
    GPIO_Init(GPIOA,&iodef);  
    iodef.GPIO_Pin=GPIO_Pin_12;
    GPIO_Init(GPIOB,&iodef);
    Run_On();
    Flag_LED_Off();
#endif
#ifdef USING_BOARD_RED  
    RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB|,ENABLE); 
    iodef.GPIO_Pin=GPIO_Pin_10;
    iodef.GPIO_Mode=GPIO_Mode_Out_OD;
    iodef.GPIO_Speed=GPIO_Speed_50MHz;
    GPIO_Init(GPIOB,&iodef);  
    Run_On();
#endif
    
    
}

void LED_Run_Flash()
{
    ++cnt_1s;
    if(cnt_1s==1000)
    {
        
        switch(flag_LED_Run)
        {
            case 0:
            Run_On();
#ifdef USING_BOARD_YELLOW     
            Flag_LED_Off();
#endif             
            flag_LED_Run=1;
            break;
            case 1:
            Run_Off();
#ifdef USING_BOARD_YELLOW     
            Flag_LED_On();
#endif 
            flag_LED_Run=0;
            break;
        }
        cnt_1s=0;
    }
}